<?php

namespace App\Http\Controllers\home\user;


use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use App\Models\Coupon;


class CouponController extends Controller
{
    public function redatas()
    {
        //dd(time());
        $id = session("homeuser");
        $list = Coupon::where('user_id', $id)->get();
        $la = [];
        $lb = [];
        $lc = [];
        foreach ($list as $v) {
            //已过期
            if ($v->status == 1 && $v->end < time()) {
                $la[] = $v;
            }
            //未使用
            if ($v->status == 1 && $v->end > time()) {
                $lb[] = $v;
            }
            //已使用
            if ($v->status == 2 ) {
                $lc[] = $v;
            }
        }
        return view("home.user.coupon", ['la' => $la, 'lb' => $lb, 'lc' => $lc]);
    }
}
